From 1e5f5a953588cefa75396454c9aed0a79552db14 Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Thu, 3 Jul 2025 13:09:53 +0300 Subject: Migrate notes to micro --- src/pages/micro/[...slug].astro | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/pages/micro/[...slug].astro (limited to 'src/pages/micro/[...slug].astro') diff --git a/src/pages/micro/[...slug].astro b/src/pages/micro/[...slug].astro new file mode 100644 index 0000000..2ce847d --- /dev/null +++ b/src/pages/micro/[...slug].astro @@ -0,0 +1,31 @@ +--- +import { getCollection } from "astro:content"; + +import Note from "@/components/note/Note.astro"; +import PageLayout from "@/layouts/Base.astro"; +import type { GetStaticPaths, InferGetStaticPropsType } from "astro"; + +// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr +export const getStaticPaths = (async () => { + const allNotes = await getCollection("note"); + return allNotes.map((note) => ({ + params: { slug: note.id }, + props: { note }, + })); +}) satisfies GetStaticPaths; + +export type Props = InferGetStaticPropsType; + +const { note } = Astro.props; + +const meta = { + description: + note.data.description || + `Read about my note posted on: ${note.data.publishDate.toLocaleDateString()}`, + title: note.data.title, +}; +--- + + + + -- cgit v1.2.3